package views;

import utils.MessageUtils;
import utils.SessionUtils;
import views.components.Header;

import com.vaadin.annotations.Theme;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
import config.Parameters;

@SuppressWarnings("serial")
@Theme("Theme02")
/**
 * Clase que es mostra al fer logout
 *
 */
public class LogOutView extends CustomComponent implements View,
		Button.ClickListener {
	private final Button btLogin;
	private Header header;
	private VerticalLayout root;

	public LogOutView() {
		header = new Header(MessageUtils.getI18n("logout"));
		root = new VerticalLayout();
		btLogin = new Button(MessageUtils.getI18n("login_to_system"), this);

		root.addComponents(header, btLogin);
		root.setComponentAlignment(header, Alignment.TOP_CENTER);
		root.setComponentAlignment(btLogin, Alignment.BOTTOM_CENTER);

		setCompositionRoot(root);
	}

	@Override
	public void enter(ViewChangeEvent event) {

	}

	@Override
	public void buttonClick(ClickEvent event) {
		// Navigate to main view
		SessionUtils.setSessionUser(null);
		getUI().getNavigator().navigateTo(Parameters.LOGIN_VIEW_NAME);
	}

}
